<?php	 	 

/**
 * This is the model class for table "master".
 *
 * The followings are the available columns in table 'master':
 * @property integer $id
 * @property string $nama_master
 * @property integer $tipe_id
 * @property string $posisi_master
 *
 * The followings are the available model relations:
 * @property DataKepegawaian[] $dataKepegawaians
 * @property DataKepegawaian[] $dataKepegawaians1
 * @property DataKepegawaian[] $dataKepegawaians2
 * @property DataKepegawaian[] $dataKepegawaians3
 * @property DataKepegawaian[] $dataKepegawaians4
 * @property DataKepegawaian[] $dataKepegawaians5
 * @property DataKepegawaian[] $dataKepegawaians6
 * @property DataKepegawaian[] $dataKepegawaians7
 * @property ManajemenDataPok[] $manajemenDataPoks
 * @property TipeMaster $tipe
 */
class Master extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Master the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'master';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama_master, tipe_id, posisi_master', 'required'),
			array('tipe_id', 'numerical', 'integerOnly'=>true),
			array('nama_master, posisi_master', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, nama_master, tipe_id, posisi_master', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'dataKepegawaians' => array(self::HAS_MANY, 'DataKepegawaian', 'jabatan_funsional'),
			'dataKepegawaians1' => array(self::HAS_MANY, 'DataKepegawaian', 'jenis_kelamin'),
			'dataKepegawaians2' => array(self::HAS_MANY, 'DataKepegawaian', 'agama'),
			'dataKepegawaians3' => array(self::HAS_MANY, 'DataKepegawaian', 'status_pernikahan'),
			'dataKepegawaians4' => array(self::HAS_MANY, 'DataKepegawaian', 'bidang'),
			'dataKepegawaians5' => array(self::HAS_MANY, 'DataKepegawaian', 'status_pegawai'),
			'dataKepegawaians6' => array(self::HAS_MANY, 'DataKepegawaian', 'golongan_cpns'),
			'dataKepegawaians7' => array(self::HAS_MANY, 'DataKepegawaian', 'jabatan_struktural'),
			'manajemenDataPoks' => array(self::HAS_MANY, 'ManajemenDataPok', 'unit_kerja_id'),
			'tipe' => array(self::BELONGS_TO, 'TipeMaster', 'tipe_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nama_master' => 'Nama Master',
			'tipe_id' => 'Tipe',
			'posisi_master' => 'Posisi Master',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nama_master',$this->nama_master,true);
		$criteria->compare('tipe_id',$this->tipe_id);
		$criteria->compare('posisi_master',$this->posisi_master,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}